package cn.openea.perpartner.meily.web.controller;



import cn.openea.perpartner.common.core.web.controller.BaseController;
import cn.openea.perpartner.common.core.web.domain.AjaxResult;
import cn.openea.perpartner.common.core.web.page.TableDataInfo;
import cn.openea.perpartner.meily.web.entity.BehaviorConfig;
import cn.openea.perpartner.meily.web.service.IBehaviorConfigService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * (BehaviorConfig)表控制层
 *
 * @author Weird077
 * @since 2023-06-09 16:09:09
 */
@RestController
@RequestMapping("/behavior/config")
public class BehaviorConfigController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private IBehaviorConfigService behaviorConfigService;

    @PostMapping("/list")
    public TableDataInfo selectBehaviorConfigList(@RequestBody BehaviorConfig behaviorConfig) {
        startPage();
        List<BehaviorConfig> list = behaviorConfigService.selectBehaviorConfigList(behaviorConfig);
        return getDataTable(list);
    }

    @GetMapping("{id}")
    public AjaxResult selectBehaviorConfig(@PathVariable Serializable id) {
        return success(behaviorConfigService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param behaviorConfig 实体对象
     * @return 新增结果
     */
    @PostMapping("/add")
    public AjaxResult insertBehaviorConfig(@RequestBody BehaviorConfig behaviorConfig) {
        return success(this.behaviorConfigService.save(behaviorConfig));
    }

    /**
     * 修改数据
     *
     * @param behaviorConfig 实体对象
     * @return 修改结果
     */
    @PostMapping("/edit")
    public AjaxResult updateBehaviorConfig(@RequestBody BehaviorConfig behaviorConfig) {
        return success(this.behaviorConfigService.updateById(behaviorConfig));
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @PostMapping("/delete")
    public AjaxResult deleteBehaviorConfig(@RequestBody List<Long> idList) {
        return success(this.behaviorConfigService.removeByIds(idList));
    }
}

